/*
 * RecentTripQueries.java
 *
 * Created on August 29, 2007, 12:30 AM
 *
 * Copyright 2008 David D. Emory
 * 
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.fpdev.apps.admin.analysis;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author demory
 */
public class RecentTripQueries {

  private List<TripQuery> queries_;
  private int maxSize_;

  /** Creates a new instance of RecentTripQueries */
  public RecentTripQueries(int maxSize) {
    queries_ = new LinkedList<TripQuery>();
    maxSize_ = maxSize;
  }

  public void addQuery(String start, String end, int hour, int min, int ampm, int day) {
    queries_.add(0, new TripQuery(start, end, hour, min, ampm, day));
    while (queries_.size() > maxSize_) {
      queries_.remove(queries_.size() - 1);
    }
  }

  public void select(int i) {

  }

  public Iterator<String> getDescriptions() {
    List<String> descriptions = new LinkedList<String>();
    Iterator<TripQuery> queries = queries_.iterator();
    while (queries.hasNext()) {
      descriptions.add(queries.next().getDescription());
    }
    return descriptions.iterator();
  }

  public class TripQuery {

    private String start_,  end_;
    private int hour_,  min_,  ampm_,  day_;

    public TripQuery(String start, String end, int hour, int min, int ampm, int day) {
      start_ = start;
      end_ = end;
      hour_ = hour;
      min_ = min;
      ampm_ = ampm;
      day_ = day;
    }

    public String getDescription() {
      return start_ + " to " + end_;
    }
  }
}
